package com.tfy.liquor.dao;

import com.tfy.liquor.bean.AdminUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

/**
 * 管理员信息
 */
@Mapper
@Service
public interface AdminUserDao {
    // 添加管理员信息
    @Insert("insert into admin_user values(null, ${userName}, ${salt}, ${password}, ${realName}, ${avatar}, ${phone}, ${email}, ${sex}, ${status}, ${createTime})")
    int addAdminUser(AdminUser adminUser);

    // 根据管理员账号信息获取账户所有信息
//    @Select("select * from admin_user where userName=${userName}")
    @Select({"<script>" +
            "select * from admin_user " +
            "where 1=1" +
            "<if test='userName!=null'> and userName='${userName}'</if>" +
            "</script>"})
    AdminUser getAdminUserInfo(String userName);

    // 根据管理员账号信息获取账户信息
    @Select("select salt from admin_user where userName=${userName}")
    String getAdminUser(String userName);

    // 管理员登录
    @Select("select * from admin_user where userName=${userName} and password=${password}")
    AdminUser adminUserLogin(AdminUser adminUser);
}
